/*
package com.imooc.coupon.serilization;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import CouponTemplate;

import java.io.IOException;
import java.text.SimpleDateFormat;

*/
/**
 * @Author Administrator
 * @Date 2021/8/24 21:08
 * @Version 1.0
 *//*

public class CouponTemplateSerialize extends JsonSerializer<CouponTemplate> {

    @Override
    public void serialize(CouponTemplate template,
                          JsonGenerator jsonGenerator,
                          SerializerProvider serializerProvider) throws IOException {
        //开始序列化对象
        jsonGenerator.writeStartObject();

        jsonGenerator.writeStringField("id", template.getId().toString());
        jsonGenerator.writeStringField("name", template.getName());
        jsonGenerator.writeStringField("logo", template.getLogo());
        jsonGenerator.writeStringField("desc", template.getDesc());
        jsonGenerator.writeStringField("category", template.getCategory().getDescription());
        jsonGenerator.writeStringField("productLine", template.getProductLine().getDescription());
        jsonGenerator.writeStringField("count", template.getCount().toString());
        jsonGenerator.writeStringField("createTime",
                new SimpleDateFormat("yyyy-MM-dd HH:ss:mm").format(template.getCreateTime()));

        jsonGenerator.writeStringField("userId", template.getUserId().toString());
        jsonGenerator.writeStringField("key", template.getKey() + String.format("%04d", template.getId()));
        jsonGenerator.writeStringField("target", template.getTarget().getDescription());
        jsonGenerator.writeStringField("rule", JSON.toJSONString(template.getRule()));

    }
}
*/
